package com.example.javafx.单选按钮;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.HBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        HBox root = new HBox();
        Scene scene = new Scene(root,300,150);
        primaryStage.setScene(scene);
        primaryStage.setTitle("");

        ToggleGroup group = new ToggleGroup();
        RadioButton button1 = new RadioButton("select first");
        button1.setToggleGroup(group);
        button1.setSelected(true);

        RadioButton button2 = new RadioButton("select second");
        button2.setToggleGroup(group);

        root.getChildren().addAll(button1,button2);
        //scene.setRoot(root);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
